<% layout('/layouts/default.html', {title: '教师信息表管理', libs: ['dataGrid']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-notebook"></i> ${text('教师信息表管理')}
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
				<% if(hasPermi('mx:mxTeacher:edit')){ %>
					<a href="${ctx}/mx/mxTeacher/form" class="btn btn-default btnTool" title="${text('新增教师信息表')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
					<a href="${ctx}/mx/mxTeacher/wudi" id="wudi" class="btn btn-default" title="${text('新增教师信息表')}">${text('无敌新增')}</a>
				<% } %>
				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
			</div>
		</div>
		<div class="box-body">
			<#form:form id="searchForm" model="${mxTeacher}" action="${ctx}/mx/mxTeacher/listData" method="post" class="form-inline hide"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
				<div class="form-group">
					<label class="control-label">${text('教师姓名')}：</label>
					<div class="control-inline">
						<#form:input path="mxName" maxlength="100" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('教师籍贯')}：</label>
					<div class="control-inline">
						<#form:input path="mxHometown" maxlength="100" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('教师所在地区')}：</label>
					<div class="control-inline">
						<#form:input path="mxRegion" maxlength="100" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('教师评分')}：</label>
					<div class="control-inline">
						<#form:input path="mxScore" maxlength="50" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label">${text('教师所属单位')}：</label>
					<div class="control-inline">
						<#form:input path="mxUnit" maxlength="100" class="form-control width-120"/>
					</div>
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
					<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
				</div>
			</#form:form>
			<table id="dataGrid"></table>
			<div id="dataGridPage"></div>
		</div>
	</div>
</div>
<% } %>
<script>
	$(document).ready(function() {
		// 绑定按钮的点击事件
		$("#wudi").click(function(event) {
			// 阻止默认行为（如表单提交或链接跳转）
			event.preventDefault();

			// 发送 AJAX 请求
			$.ajax({
				url: $(this).attr("href"), // 获取按钮的 href 属性作为请求地址
				type: "GET", // 请求方法（GET 或 POST）
				dataType: "json", // 预期返回的数据类型为 JSON
				success: function(data) {
					// 请求成功时的回调函数
					console.log("返回的数据:", data);
					alert("增加成功");
					$('#dataGrid').dataGrid('reloadGrid');
				}
			});
		});
	});


// 初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'${text("教师姓名")}', name:'mxName', index:'a.mx_name', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/mx/mxTeacher/form?mxId='+row.mxId+'" class="btnList" data-title="${text("编辑教师信息表")}">'+(val||row.id)+'</a>';
		}},
		{header:'${text("教师籍贯")}', name:'mxHometown', index:'a.mx_hometown', width:150, align:"left"},
		{header:'${text("教师所在地区")}', name:'mxRegion', index:'a.mx_region', width:150, align:"left"},
		{header:'${text("教师评分")}', name:'mxScore', index:'a.mx_score', width:150, align:"left"},
		{header:'${text("教师所属单位")}', name:'mxUnit', index:'a.mx_unit', width:150, align:"left"},
		{header:'${text("操作")}', name:'actions', width:120, formatter: function(val, obj, row, act){
			var actions = [];
			//<% if(hasPermi('mx:mxTeacher:edit')){ %>
				actions.push('<a href="${ctx}/mx/mxTeacher/form?mxId='+row.mxId+'" class="btnList" title="${text("编辑教师信息表")}"><i class="fa fa-pencil"></i></a>&nbsp;');
				actions.push('<a href="${ctx}/mx/mxTeacher/delete?mxId='+row.mxId+'" class="btnList" title="${text("删除教师信息表")}" data-confirm="${text("确认要删除该教师信息表吗？")}"><i class="fa fa-trash-o"></i></a>&nbsp;');
			//<% } %>
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>